package com.maple.blog.api;

import com.maple.blog.bean.MessageBean;
import com.maple.blog.bean.ResponseBean;
import com.maple.blog.tools.DingTalkTools;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.beans.ConstructorProperties;

/**
 * 描述: CommonApi
 *
 * @author hz.lei
 * @date 2018年04月27日 下午11:19
 */
@RestController
@RequestMapping({"/api/common"})
public class CommonApi {

    private static final Logger log = LogManager.getLogger(CommonApi.class);
    private final DingTalkTools dingTalkTools;

    @PostMapping({"/message"})
    public ResponseBean message(MessageBean messageBean) {
        this.dingTalkTools.textMessage(messageBean);
        return ResponseBean.success((Object) null);
    }

    @ConstructorProperties({"dingTalkTools"})
    public CommonApi(final DingTalkTools dingTalkTools) {
        this.dingTalkTools = dingTalkTools;
    }
}
